package com.myNovel.novel.service.impl;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.myNovel.novel.core.common.resp.RestResp;
import com.myNovel.novel.dto.resp.HomeBookRespDto;
import com.myNovel.novel.dto.resp.ImgVerifyCodeRespDto;
import com.myNovel.novel.manager.VerifyCodeManager;
import com.myNovel.novel.service.ResourceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @Author：Guxx
 * @Package：com.myNovel.novel.service.impl
 * @Date：2024/3/30 13:08
 * @Filename：ResourceServiceImpl
 */
@Service
@RequiredArgsConstructor
public class ResourceServiceImpl implements ResourceService {
    VerifyCodeManager verifyCodeManager;
    @Override
    public RestResp<ImgVerifyCodeRespDto> getImgVerifyCode() throws IOException {
        String sessionId = IdWorker.get32UUID();
        return RestResp.ok(ImgVerifyCodeRespDto.builder()
                .sessionId(sessionId)
                .img(verifyCodeManager.genImgVerifyCode(sessionId))
                .build());
    }
}
